package com.utility.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.utility.project.common.constants.YsConstant;
import com.utility.project.entity.YsBsSetting;
import com.utility.project.mapper.YsBsSettingMapper;
import com.utility.project.service.IYsBsSettingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author yangzhiguo
 * @date 2024-10-19
 * @description 
 */
@Service
public class YsBsSettingServiceImpl extends ServiceImpl<YsBsSettingMapper, YsBsSetting> implements IYsBsSettingService {

    @Override
    public YsBsSetting queryByCode(String code) {
        QueryWrapper<YsBsSetting> wrapper = new QueryWrapper();
        wrapper.eq("code", code).eq("enable", 1);
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public Boolean queryAppBooleanValue() {
        YsBsSetting ysBsSetting = queryByCode(YsConstant.APP_BOOLEAN_CODE);
        //小程序value设置为0表示false，为1表示true
        if (ysBsSetting != null) {
            return Objects.equals(ysBsSetting.getValue(),"0")?false:true;
        }
        return null;
    }
}
